/**
 * File: cs3343-Satir-Therapy/src/program/BoardProcessor.java
 *  
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.0.0
 * Checked in at date: 2012/02/05 18:32
 * Checked out at date: 2012/02/12 12:55
 * Log: creation of BoardProcessor class, and draw()
 * 
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.1.0
 * Checked in at date: 2012/02/12 15:44
 * Checked out at date: 2012/02/13 21:55
 * Log: rename looping variables into the meaningful ones. E.g: k is renamed into row, i is renamed into miniRow, j is renamed into grid 
 *
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.2.0
 * Checked in at date: 2012/02/13 22:35
 * Checked out at date: 2012/02/21 23:16
 * Log: redefine draw() from draw(player) into draw(p1, p2) 
 * 
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.3.0
 * Checked in at date: 2012/02/28 09:50
 * Checked out at date: 2012/03/05 20:48
 * Log: redefine draw(p1, p2) into draw(players), accommodate 6 players instead of 2 players, 
 *      extract the repeating displaying player into a showPlayer(playerA, playerB, playerC, grid, miniRow)
 *      display player information in the center of the board
 * 
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.4.0
 * Checked in at date: 
 * Log: rename draw() into setBoard()
 * 		resize the board from 8 grids x 7 grids into 8 grids x 8 grids
 * 		define isToolGrid(), isEventGrid() and isSayAndActionGrid() to check whether any player step onto tool card grid, event card grid, say & action card grid
 * 		extract the repeating code into showPlayer()
 * 		
 *      
 */
package program;
import java.util.*;

public class BoardProcessor {
	// 
	
	Board board = new Board();
	
	public boolean isMagicToolGrid(int grid){
		int magicToolGrid[] = board.getMagicToolGrid();
		
		for(int i=0; i< magicToolGrid.length; i++){
			if(grid==magicToolGrid[i]){
				return true;
			}
		}
		return false;
	}
	
	public boolean isEventGrid(int grid){
		int eventGrid[] = board.getEventGrid();
		
		for(int i=0; i< eventGrid.length; i++){
			if(grid==eventGrid[i]){
				return true;
			}
		}
		return false;
	}
	
	public boolean isSayAndActionGrid(int grid){
		int sayAndActionGrid[] = board.getSayAndActionGrid();
		
		for(int i=0; i< sayAndActionGrid.length; i++){
			if(grid==sayAndActionGrid[i]){
				return true;
			}
		}
		return false;
	}
	
	public void showPlayer(Player playerA, Player playerB, Player playerC, int grid, int miniRow){
		if(playerA.getPosition()==grid && playerB.getPosition()!=grid && playerC.getPosition()!=grid){
			if(grid>=9 && grid<=14){
				if(miniRow==1)
					System.out.print("P1      |");
				else
					System.out.print("P4      |");				
			}
			else{
				if(miniRow==1)
					System.out.print("|P1      ");
				else
					System.out.print("|P4      ");
			}
		}
		else if(playerA.getPosition()!=grid && playerB.getPosition()==grid && playerC.getPosition()!=grid){
			if(grid>=9 && grid<=14){
				if(miniRow==1)
					System.out.print("   P2   |");
				else
					System.out.print("   P5   |");	
			}
			else{
				if(miniRow==1)
					System.out.print("|   P2   ");
				else
					System.out.print("|   P5   ");					
			}
		}
		else if(playerA.getPosition()!=grid && playerB.getPosition()!=grid && playerC.getPosition()==grid){
			if(grid>=9 && grid<=14){
				if(miniRow==1)
					System.out.print("      P3|");
				else
					System.out.print("      P6|");
			}
			else{
				if(miniRow==1)
					System.out.print("|      P3");
				else
					System.out.print("|      P6");				
			}
		}
		else if(playerA.getPosition()==grid && playerB.getPosition()==grid && playerC.getPosition()!=grid){
			if(grid>=9 && grid<=14){
				if(miniRow==1)
					System.out.print("P1 P2   |");
				else
					System.out.print("P4 P5   |");
			}
			else{
				if(miniRow==1)
					System.out.print("|P1 P2   ");
				else
					System.out.print("|P4 P5   ");				
			}
		}
		else if(playerA.getPosition()==grid && playerB.getPosition()!=grid && playerC.getPosition()==grid){
			if(grid>=9 && grid<=14){
				if(miniRow==1)
					System.out.print("P1    P3|");
				else
					System.out.print("P4    P6|");
			}
			else{				
				if(miniRow==1)
					System.out.print("|P1    P3");
				else
					System.out.print("|P4    P6");
			}
		}
		else if(playerA.getPosition()!=grid && playerB.getPosition()==grid && playerC.getPosition()==grid){
			if(grid>=9 && grid<=14){
				if(miniRow==1)
					System.out.print("   P2 P3|");
				else
					System.out.print("   P5 P6|");
			}
			else{				
				if(miniRow==1)
					System.out.print("|   P2 P3");
				else
					System.out.print("|   P5 P6");
			}
		}
		else if(playerA.getPosition()==grid && playerB.getPosition()==grid && playerC.getPosition()==grid){
			if(grid>=9 && grid<=14){
				if(miniRow==1)
					System.out.print("P1 P2 P3|");
				else
					System.out.print("P4 P5 P6|");
			}
			else{
				if(miniRow==1)
					System.out.print("|P1 P2 P3");
				else
					System.out.print("|P4 P5 P6");				
			}
		}		
		else{
			if(grid>=9 && grid<=14)
				System.out.print("        |");
			else
				System.out.print("|        ");
		}
	}
	
	
	// Request for displaying the board
	public void setBoard(Vector<Player> players){
		int numberOfPlayers = players.size();

		Player p1 = new Player();
		Player p2 = new Player();
		Player p3 = new Player();
		Player p4 = new Player();
		Player p5 = new Player();
		Player p6 = new Player();
		
		if(numberOfPlayers>=2){
			p1 = players.get(0);
			p2 = players.get(1);
		}
		if(numberOfPlayers>=3){
			p3 = players.get(2);
		}
		if(numberOfPlayers>=4){
			p4 = players.get(3);
		}
		if(numberOfPlayers>=5){
			p5 = players.get(4);
		}
		if(numberOfPlayers==6){
			p6 = players.get(5);
		}			
		
		// 1st row edge 		
		for(int edge=0; edge<8; edge++)
			System.out.print("---------");
		
		System.out.println("-");
		// 1st row
		for(int miniRow=1; miniRow<=3; miniRow++){
			for(int grid=1; grid<=8; grid++){
				if(miniRow==2 && isEventGrid(grid)){
					System.out.print("|    E   ");
				}
				else if(miniRow==2 && isSayAndActionGrid(grid)){
					System.out.print("|   S/A  ");
				}
				else if(miniRow==2 && isMagicToolGrid(grid)){
					System.out.print("|    M   ");
				}
				else{
					if(miniRow==1){
						showPlayer(p1, p2, p3, grid, miniRow);
					}
					else if(miniRow==3){
						showPlayer(p4, p5, p6, grid, miniRow);
					}
					else{
						System.out.print("|        ");
					}
				}
			}
			System.out.println("|");
		
		}
				
		for(int edge=0; edge<8; edge++)
			System.out.print("---------");
		
		System.out.println("-");
		
		// 2nd row - 7th row
		for(int row=2; row<=7; row++){
			for(int miniRow=1; miniRow<=3; miniRow++){
				for(int cell=1; cell<=2; cell++){
					if(row==3 && miniRow==2 && cell==1){						
						System.out.print("|    E   ");
					}
					else if(row==5 && miniRow==2 && cell==1){						
						System.out.print("|   S/A  ");
					}
					else if(row==7 && miniRow==2 && cell==1){						
						System.out.print("|    M   ");
					}
					else{
						if(row==2){
							if(miniRow==1 && cell==1){
								showPlayer(p1, p2, p3, 28, miniRow);
							}
							else if(miniRow==3 && cell==1){
								showPlayer(p4, p5, p6, 28, miniRow);
							}
							else{
									System.out.print("|        ");
							}							
						}
						if(row==3){
							if(miniRow==1 && cell==1){
								showPlayer(p1, p2, p3, 27, miniRow);
							}
							else if(miniRow==3 && cell==1){
								showPlayer(p4, p5, p6, 27, miniRow);
							}
							else{
								System.out.print("|        ");
							}
						}
						if(row==4){
							if(miniRow==1 && cell==1){
								showPlayer(p1, p2, p3, 26, miniRow);
							}
							else if(miniRow==3 && cell==1){
								showPlayer(p4, p5, p6, 26, miniRow);
							}
							else{
								System.out.print("|        ");
							}
						}
						if(row==5){
							if(miniRow==1 && cell==1){
								showPlayer(p1, p2, p3, 25, miniRow);
							}
							else if(miniRow==3 && cell==1){
								showPlayer(p4, p5, p6, 25, miniRow);
							}
							else{
								System.out.print("|        ");
							}
						}
						if(row==6){
							if(miniRow==1 && cell==1){
								showPlayer(p1, p2, p3, 24, miniRow);
							}
							else if(miniRow==3 && cell==1){
								showPlayer(p4, p5, p6, 24, miniRow);
							}
							else{
								System.out.print("|        ");
							}
						}
						if(row==7){
							if(miniRow==1 && cell==1){
								showPlayer(p1, p2, p3, 23, miniRow);
							}
							else if(miniRow==3 && cell==1){
								showPlayer(p4, p5, p6, 23, miniRow);
							}
							else{
								System.out.print("|        ");
							}
						}
					}
				}
				
				for(int cell=3; cell<=6; cell++){
					if(row==2 && miniRow==2 && cell==3)
						System.out.print("Player No");
					else if(row==2 && miniRow==2 && cell==4)
						System.out.print("  Name   ");
					else if(row==2 && miniRow==2 && cell==5)
						System.out.print("  Role   ");
					else if(row==2 && miniRow==2 && cell==6)
						System.out.print(" Esteem  ");
					else if(row==2 && miniRow==3)
						System.out.print("---------");
					else if(row==3 && miniRow==1 && cell==3)
						System.out.print("    01   ");
					else if(row==3 && miniRow==1 && cell==4){
						System.out.print(p1.getName());
						int nameLength = 9 - p1.getName().length();						
						if(nameLength>0){
							for(int i=0; i<nameLength; i++){
								System.out.print(" ");
							}
						}
					}
					else if(row==3 && miniRow==1 && cell==5){
						System.out.print(p1.getRole());
						//String selfesteem = String.valueOf(p1.getSelfEsteem());
						int nameLength = 9 - p1.getRole().length();						
						if(nameLength>0){
							for(int i=0; i<nameLength; i++){
								System.out.print(" ");
							}
						}
					}
					else if(row==3 && miniRow==1 && cell==6){
						System.out.print(p1.getSelfEsteem());
						String selfesteem = String.valueOf(p1.getSelfEsteem());
						int nameLength = 9 - selfesteem.length();						
						if(nameLength>0){
							for(int i=0; i<nameLength; i++){
								System.out.print(" ");
							}
						}
					}
					else if(row==3 && miniRow==2 && cell==3)
						System.out.print("    02   ");
					else if(row==3 && miniRow==2 && cell==4){
						System.out.print(p2.getName());
						int nameLength = 9 - p2.getName().length();						
						if(nameLength>0){
							for(int i=0; i<nameLength; i++){
								System.out.print(" ");
							}
						}
					}
					else if(row==3 && miniRow==2 && cell==5){
						System.out.print(p2.getRole());
						int nameLength = 9 - p2.getRole().length();						
						if(nameLength>0){
							for(int i=0; i<nameLength; i++){
								System.out.print(" ");
							}
						}
					}
					else if(row==3 && miniRow==2 && cell==6){
						System.out.print(p2.getSelfEsteem());
						String selfesteem = String.valueOf(p2.getSelfEsteem());
						int nameLength = 9 - selfesteem.length();						
						if(nameLength>0){
							for(int i=0; i<nameLength; i++){
								System.out.print(" ");
							}
						}
					}
					else{
						if(numberOfPlayers==3){
							if(row==3 && miniRow==3 && cell==3)
								System.out.print("    03   ");
							else if(row==3 && miniRow==3 && cell==4){
								System.out.print(p3.getName());
								int nameLength = 9 - p3.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==5){
								System.out.print(p3.getRole());
								int nameLength = 9 - p3.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==6){
								System.out.print(p3.getSelfEsteem());
								String selfesteem = String.valueOf(p3.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else
								System.out.print("         ");
						}
						else if(numberOfPlayers==4){
							if(row==3 && miniRow==3 && cell==3)
								System.out.print("    03   ");
							else if(row==3 && miniRow==3 && cell==4){
								System.out.print(p3.getName());
								int nameLength = 9 - p3.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==5){
								System.out.print(p3.getRole());
								int nameLength = 9 - p3.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==6){
								System.out.print(p3.getSelfEsteem());
								String selfesteem = String.valueOf(p3.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==3)
								System.out.print("    04   ");
							else if(row==4 && miniRow==1 && cell==4){
								System.out.print(p4.getName());
								int nameLength = 9 - p4.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==5){
								System.out.print(p4.getRole());
								int nameLength = 9 - p4.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==6){
								System.out.print(p4.getSelfEsteem());
								String selfesteem = String.valueOf(p4.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else{
								System.out.print("         ");
							}
						}
						else if(numberOfPlayers==5){
							if(row==3 && miniRow==3 && cell==3)
								System.out.print("    03   ");
							else if(row==3 && miniRow==3 && cell==4){
								System.out.print(p3.getName());
								int nameLength = 9 - p3.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==5){
								System.out.print(p3.getRole());
								int nameLength = 9 - p3.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==6){
								System.out.print(p3.getSelfEsteem());
								String selfesteem = String.valueOf(p3.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==3)
								System.out.print("    04   ");
							else if(row==4 && miniRow==1 && cell==4){
								System.out.print(p4.getName());
								int nameLength = 9 - p4.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==5){
								System.out.print(p4.getRole());
								int nameLength = 9 - p4.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==6){
								System.out.print(p4.getSelfEsteem());
								String selfesteem = String.valueOf(p4.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==2 && cell==3){
								System.out.print("    05   ");
								
							}
							else if(row==4 && miniRow==2 && cell==4){
								System.out.print(p5.getName());
								int nameLength = 9 - p5.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==2 && cell==5){
								System.out.print(p5.getRole());
								int nameLength = 9 - p5.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==2 && cell==6){
								System.out.print(p5.getSelfEsteem());
								String selfesteem = String.valueOf(p5.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else
								System.out.print("         ");
						}
						else if(numberOfPlayers==6){
							if(row==3 && miniRow==3 && cell==3)
								System.out.print("    03   ");
							else if(row==3 && miniRow==3 && cell==4){
								System.out.print(p3.getName());
								int nameLength = 9 - p3.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==5){
								System.out.print(p3.getRole());								
								int nameLength = 9 - p3.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==3 && miniRow==3 && cell==6){
								System.out.print(p3.getSelfEsteem());
								String selfesteem = String.valueOf(p3.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==3)
								System.out.print("    04   ");
							else if(row==4 && miniRow==1 && cell==4){
								System.out.print(p4.getName());
								int nameLength = 9 - p4.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==5){
								System.out.print(p4.getRole());
								int nameLength = 9 - p4.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==1 && cell==6){
								System.out.print(p4.getSelfEsteem());
								String selfesteem = String.valueOf(p4.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==2 && cell==3){
								System.out.print("    05   ");
								
							}
							else if(row==4 && miniRow==2 && cell==4){
								System.out.print(p5.getName());
								int nameLength = 9 - p5.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==2 && cell==5){
								System.out.print(p5.getRole());
								int nameLength = 9 - p5.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==2 && cell==6){
								System.out.print(p5.getSelfEsteem());
								String selfesteem = String.valueOf(p5.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==3 && cell==3)
								System.out.print("    06   ");
							else if(row==4 && miniRow==3 && cell==4){
								System.out.print(p6.getName());
								int nameLength = 9 - p6.getName().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==3 && cell==5){
								System.out.print(p6.getRole());
								int nameLength = 9 - p6.getRole().length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else if(row==4 && miniRow==3 && cell==6){
								System.out.print(p6.getSelfEsteem());
								String selfesteem = String.valueOf(p6.getSelfEsteem());
								int nameLength = 9 - selfesteem.length();						
								if(nameLength>0){
									for(int i=0; i<nameLength; i++){
										System.out.print(" ");
									}
								}
							}
							else
								System.out.print("         ");
						}
						else
							System.out.print("         ");
					}
				}
			
				System.out.print(" ");
				
				for(int cell=7; cell<=8; cell++){
					if(row==3 && miniRow==2 && cell==8){
						System.out.print("   S/A  |");
					}
					else if(row==5 && miniRow==2 && cell==8){
						System.out.print("    E   |");
					}
					else if(row==6 && miniRow==2 && cell==8){
						System.out.print("    M   |");
					}
					else{
						if(row==2){
							if(miniRow==1 && cell==8){
								showPlayer(p1, p2, p3, 9, miniRow);
							}
							else if(miniRow==3 && cell==8){
								showPlayer(p4, p5, p6, 9, miniRow);
							}
							else{
								System.out.print("        |");
							}
						}
						if(row==3){
							if(miniRow==1 && cell==8){
								showPlayer(p1, p2, p3, 10, miniRow);
							}
							else if(miniRow==3 && cell==8){
								showPlayer(p4, p5, p6, 10, miniRow);
							}
							else{
								System.out.print("        |");
							}
						}
						if(row==4){
							if(miniRow==1 && cell==8){
								showPlayer(p1, p2, p3, 11, miniRow);
							}
							else if(miniRow==3 && cell==8){
								showPlayer(p4, p5, p6, 11, miniRow);
							}
							else{
								System.out.print("        |");
							}
						}
						if(row==5){
							if(miniRow==1 && cell==8){
								showPlayer(p1, p2, p3, 12, miniRow);
							}
							else if(miniRow==3 && cell==8){
								showPlayer(p4, p5, p6, 12, miniRow);
							}
							else{
								System.out.print("        |");
							}
						}
						if(row==6){
							if(miniRow==1 && cell==8){
								showPlayer(p1, p2, p3, 13, miniRow);
							}
							else if(miniRow==3 && cell==8){
								showPlayer(p4, p5, p6, 13, miniRow);
							}
							else{
								System.out.print("        |");
							}
						}
						if(row==7){
							if(miniRow==1 && cell==8){
								showPlayer(p1, p2, p3, 14, miniRow);
							}
							else if(miniRow==3 && cell==8){
								showPlayer(p4, p5, p6, 14, miniRow);
							}
							else{
								System.out.print("        |");
							}
						}
					}
				}
			
				System.out.println();					
			}
			
			if(row!=7){
				System.out.print("---------");
		
				for(int grid=2; grid<=7; grid++)
					System.out.print("         ");
			
				System.out.println("---------");
			}
		}
		
		// 8th row edge 		
		for(int edge=0; edge<8; edge++)
			System.out.print("---------");
		
		System.out.println("-");
		
		for(int miniRow=1; miniRow<=3; miniRow++){
			for(int grid=22; grid>=15; grid--){
				if(miniRow==2 && isEventGrid(grid)){
					System.out.print("|    E   ");
				}
				else if(miniRow==2 && isSayAndActionGrid(grid)){
					System.out.print("|   S/A  ");
				}
				else if(miniRow==2 && isMagicToolGrid(grid)){
					System.out.print("|    M   ");
				}
				else{
					if(miniRow==1){
						showPlayer(p1, p2, p3, grid, miniRow);
					}
					else if(miniRow==3){
						showPlayer(p4, p5, p6, grid, miniRow);
					}
					else{
						System.out.print("|        ");
					}
				}
			}
			System.out.println("|");		
		}
				
		for(int edge=0; edge<8; edge++)
			System.out.print("---------");
		
		System.out.println("-");
	}
}
